package com.marketlive.app.b2c.struts;

import com.marketlive.system.ajp.AjpServices;
import com.sourcebeat.strutslive.common.SLActionServlet;
import java.io.IOException;
import javax.servlet.ServletException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class MarketLiveActionServlet extends SLActionServlet
{
  private static final long serialVersionUID = 1L;
  private static Log log = LogFactory.getLog(MarketLiveActionServlet.class);

  public void init() throws ServletException
  {
    log.info("*** intitializing SL Action Servlet...");
    super.init();
    AjpServices ajp = new AjpServices();
    if (ajp.isConfigured()) {
      try {
        log.info("...waking up and enabling AJP");
        String jkPort = System.getProperty("com.marketlive.system.ajp.port", "8009");
        int port = Integer.parseInt(jkPort);
        log.info(">>> initializing to port: " + port);
        ajp.enableConnectorChannel(port);

        ajp.resumeConnectorChannel();
        log.info("...PORT enabled");
      } catch (IOException e) {
        log.info("IOException enabling channel", e);
      }
    }
    else
      log.info("MOD JK is not configured in this JVM");
  }

  public void destroy()
  {
    log.info("*** destroying SL Action servlet");
    super.destroy();
    AjpServices ajp = new AjpServices();
    if (ajp.isConfigured())
      try {
        log.info(">>> disabling channel...");
        ajp.disableConnectorChannel();
      } catch (IOException e) {
        log.info("IOException disabling channel", e);
      }
  }
}